/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package diagram.connections;

import diagram.handles.Handle;
import diagram.handles.TriggerHandle;
import diagram.locations.Location;
import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Stroke;

/**
 *
 * @author Jelle
 */
public class HandleConnection extends Connection {

    private Handle handleSource;
    private Handle handleTarget;

    //voor input/output verbindingen = volle lijn
    public HandleConnection(Location source, Location target) {
        super(source, target);
    }

    public HandleConnection(Handle csource, Handle ctarget) {
        super(csource.getLocation(),ctarget.getLocation());
        this.handleSource = csource;
        this.handleTarget = ctarget;
    }

    @Override
    public void paint(Graphics2D g) {
        Stroke sOld = g.getStroke();
        g.setStroke(new BasicStroke(3.0f));
        getLine().setLine(getSource().getX(), getSource().getY(), getTarget().getX(), getTarget().getY());
        g.draw(getLine());
        g.setStroke(sOld);
    }

     public boolean contains(int x, int y) {

        System.out.println("x"+x+" y"+y);
        System.out.println("okeee"+getLine().contains(x,y));
        return getLine().contains(x,y);
    }

    /**
     * @return the handleSource
     */
    public Handle getHandleSource() {
        return handleSource;
    }

    /**
     * @param handleSource the handleSource to set
     */
    public void setHandleSource(TriggerHandle handleSource) {
        this.handleSource = handleSource;
    }

    /**
     * @return the handleTarget
     */
    public Handle getHandleTarget() {
        return handleTarget;
    }

    /**
     * @param handleTarget the handleTarget to set
     */
    public void setHandleTarget(TriggerHandle handleTarget) {
        this.handleTarget = handleTarget;
    }
}

